<template>
  <view class="md-agreement" @click="handleClick">
    <text class="vip-link" :style="{ color: props.color }" v-if="!props?.isIcon">
      {{ !!props?.hideSymbol ? props.text : `《${props.text}》` }}
    </text>
    <image v-else class="adou-tip" src="https://cdn.xmxiaomai.com/isong_static/my/Group.png" mode="widthFix"></image>
  </view>
</template>

<script setup lang="ts">
import { agreementTypeEnum } from '@/data/enum';

const props = defineProps({
  text: String,
  hideSymbol: Boolean,
  color: {
    type: String,
    default: '#00785a',
  },
  isIcon: Boolean,
});

// 跳转服务条款页面
const handleClick = () => {
  uni.navigateTo({
    url: `/pages/sub/index/userAgreement?title=${props.text}&type=${
      agreementTypeEnum[props.text as keyof typeof agreementTypeEnum]
    }`,
  });
};
</script>

<style scoped lang="scss">
.md-agreement {
  display: inline-block;
  .vip-link {
    color: #00785a;
    margin-left: 4rpx;
  }
  .adou-tip {
    width: 24rpx;
    height: 24rpx;
    margin-left: 14rpx;
  }
}
</style>
